// pages/businessInfoNext/businiessInfoNext.js
import imgUrl from "../../images/util.js"
import {formValidate} from "./validate.js"
import {filteremoji} from "../../utils/index.js"
let app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isNeedIcon:imgUrl.isNeedIcon,
    positionIcon:imgUrl.positionIcon,
    position:{},
    
      businessName:"",
      phone:"",
      name:"",
      mobile:"",
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   let name= app.globalData.selectedPosition.name||"请选择地址"
   let address= app.globalData.selectedPosition.address||""
   let latitude=app.globalData.selectedPosition.latitude
   let longitude=app.globalData.selectedPosition.longitude
  //  console.log("position",position)
   this.setData({
     position:{
      latitude:latitude,
      longitude:longitude,
       name:name,
       address:address
     }
   })

  },
  jumpMap(){
    wx.navigateTo({
      url: '../mapPosition/mapPosition',
    })
  },
  jumpNext(){
    let data={
      businessName:this.data.businessName,
      phone:this.data.phone,
      name:this.data.name,
      mobile:this.data.mobile,
    }
    if(formValidate(data,this.data.position)){
        
       app.globalData.describe={
        address:this.data.position.address,
        shopName:this.data.businessName,
        customerTel:this.data.phone,
        contactUser:this.data.name,
        contactPhone:this.data.mobile,
        longitude:this.data.longitude,
        latitude:this.data.latitude
       }

        wx.navigateTo({
          url: '../businessInformation/businessInformation',
        })
    }
  },
  bindInputMobile(e){
    this.setData({
      mobile:e.detail.value
    })
  },
  bindInputBusinessName(e){
    this.setData({
      businessName:e.detail.value
    })
  },

  bindInputName(e){
    this.setData({
      name:filteremoji(e.detail.value)  
    })
  },
  bindInputPhone(e){
    this.setData({
      phone:e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})